K.

requires("K.ui.Component").

includes("K.util.Template").
includes("K.ui.ViewPort").

provides("K.ui.Window").
run(function(I) {
    
    var Window = I.Component.descend(function(o, name) {
        var shared = {
                component : I.provides
            },
            
            viewPort = I.ViewPort();
        
        Window.ancestor.constructor.call(o, shared);
        
        K.merge(o, {
            
            width : 400,
            height : 300,
            title : "Untitled window",
            
            render : function() {
                shared.theme.apply(o);
                var e = o.element(),
                    t = I.Template(K.resource("K/ui/Window.html"));
                    
                e.addClass("window-" + name);
                e.html(t.render({
                    title : o.title,
                    component : shared.cssClass
                }));
                
                e.style({
                    "width": o.width + "px",
                    "height": o.height + "px"
                });
                
                e.find(shared.cssClass + "-content").append(viewPort.element());
            }
        });
        
    });
    
    return Window;
});